As shown in Figure 1 below,
BLAH BLAH BLAH BLAHBLAH BLAH BLAH BLAHBLAH BLAH BLAH BLAHBLAH BLAH BLAH BLAHBLAH BLAH BLAH BLAHBLAH BLAH BLAH BLAH
library(tidyverse)
library(maptools)
library(RColorBrewer)
library(classInt)
library(tmap)
library(rgdal)
library(rgeos)
library(sp)
library(sf)
library(raster)
library(tmaptools)
library(methods)
library(rprojroot)
library(magrittr)
library(leaflet)
library(classInt)
library(modEvA)
library(shinyjs)
# Data Preparation:
# data downloaded at: http://www.nomisweb.co.uk/census/2011/dc5102ew [accessed 6th Novemeber 2018]
df <- read_csv("data/no_qual_over16.csv")
#read shape for south East containing only msoa within counties
SEshp <- read_shape("shapes/SouthEast.shp", as.sf = TRUE)
# change projection to WGS84 so that tmap "view" mode works
SEshp <- set_projection(SEshp, projection = 4326)
# make new column of percentage of total
df$perc_no_qual <- (df$no_qual / df$total)*100
# merge
SEmap <- merge(SEshp, df, by.x='msoa11cd', by.y='code')
# remove counties which cross over into the
toremove <- c("Dorset", "Hertfordshire",
"Northamptonshire", "Gloucestershire",
"Outer London", "Warwickshire")
# removes values which are not (!) in toremove list
SEmap <- SEmap[!(SEmap$CTY17NM %in% toremove),]
## Mapping
# Map prerequisits
tmap_mode("view")
tmap_options(limits = c(facets.view = 13))
# Map output
map <- tm_shape(SEmap) +
tm_polygons("perc_no_qual",
style="pretty",
n=5,
palette="Blues",
midpoint=NA,
title="Population (%)",
legend.is.portrait = TRUE) +
tm_scale_bar() +
tm_facets(by = "CTY17NM", nrow = 4, ncol = 2, drop.NA.facets = TRUE) +
tm_view(set.view = 7, basemaps = c("Esri.WorldTopoMap", "Esri.WorldGrayCanvas"))
import geopandas as gpd
import pandas as pd
import numpy as np
gdf = gpd.read_file('southeastmsoa.shp')
# read in data (from https://borders.ukdataservice.ac.uk//easy_download_data.html?data=England_msoa_2011 and http://geoportal.statistics.gov.uk/datasets/8d3a9e6e7bd445e2bdcc26cdf007eac7_4?geometry=-44.385%2C49.997%2C39.243%2C58.896)
dfcty = pd.read_csv("ladtocounty.csv")
dflad = pd.read_csv("ladtomsoa.csv")
dfboth = dflad.merge(dfcty, left_on='LAD16CD', right_on='LAD17CD')
dfboth.rename(columns={'MSOA11CD': 'msoa11cd'}, inplace=True)
dfboth.to_csv('msoatocounty.csv', index=False)
dfboth = pd.read_csv('msoatocounty.csv')
# merge shapefile and
gdf = gdf.merge(new)
gdf.to_file('shapes/SouthEast.shp')